/*
 * @authors :Bin Mei
 * @date    :2017-07-28
 * @description：票交汇APP-h5
 */

import React from 'react';
import ReactDOM from 'react-dom';
import {Provider} from "react-redux";
import useBasename from 'history/lib/useBasename';
import {  Router } from 'react-router';
import App from 'src/components/App';
import Store from "src/store";
import 'src/utils/config';
import { minHistory,mBridge} from 'min-bridge';


const rootRoute = {
  path: 'app',
  component: App,
  childRoutes: [
    require('./Account/route'),//账户模块 -> 账户
    require('./User/route'),//用户模块 
    require('./Notice/route'),//平台公告
    require('./Enterprise/route'),//企业模块
    require('./About/route'),//关于我们
    require('./Other/route'),//其他分类
    {
      path: 'result', //申请结果页
      getComponent(location, cb) {
        require.ensure([], (require) => {
          cb(null, require('./Result'));
        });
      },
      onEnter: () => mBridge.doAction('setTitle', { title: '申请结果' })
    },
    {
      path: '*',
      getComponent(location, cb) {
        require.ensure([], (require) => {
          cb(null, require('./NotFoundPage'));
        });
      },
      onEnter: () => mBridge.doAction('setTitle', { title: '出错啦',class:"fff" })
    }
  ],
  indexRoute:{ onEnter: (nextState, replace) => replace('/app/invest') }, //默认重定向到->投资列表
};
function Basename(history, dirname) {
  return useBasename(() => history)({ basename: `/${dirname}` });
};
    // <Router routes={rootRoute} history={Basename(browserHistory,'app')} />
ReactDOM.render(
  <Provider store={Store}>
    <Router routes={rootRoute} history={minHistory} />
  </Provider>,
  document.getElementById('app')
);


